package com.steven.download.entity;

import android.os.Parcel;
import android.os.Parcelable;

import com.steven.download.DownloadStatus;

/**
 * @Des:
 * @Author: hwz
 * @Date:2021/11/9 0009
 * @Version: 1.0
 */
public class DownInfoEntity implements   Parcelable {
    private String id;
    private String createAt;
    private String updateAt;
    private String idApp;
    private String packageName;
    private String packageSize;
    private String packageFileSize;
    private String packageMd5;
    private boolean available;
    private String packageUrl;
    public DownloadStatus downloadStatus = DownloadStatus.IDLE;

    public void setDownloadStatus(DownloadStatus downloadStatus) {
        this.downloadStatus = downloadStatus;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getCreateAt() {
        return createAt;
    }

    public void setCreateAt(String createAt) {
        this.createAt = createAt;
    }

    public String getUpdateAt() {
        return updateAt;
    }

    public void setUpdateAt(String updateAt) {
        this.updateAt = updateAt;
    }

    public String getIdApp() {
        return idApp;
    }

    public void setIdApp(String idApp) {
        this.idApp = idApp;
    }

    public String getPackageName() {
        return packageName;
    }

    public void setPackageName(String packageName) {
        this.packageName = packageName;
    }

    public String getPackageSize() {
        return packageSize;
    }

    public void setPackageSize(String packageSize) {
        this.packageSize = packageSize;
    }

    public String getPackageFileSize() {
        return packageFileSize;
    }

    public void setPackageFileSize(String packageFileSize) {
        this.packageFileSize = packageFileSize;
    }

    public String getPackageMd5() {
        return packageMd5;
    }

    public void setPackageMd5(String packageMd5) {
        this.packageMd5 = packageMd5;
    }

    public boolean isAvailable() {
        return available;
    }

    public void setAvailable(boolean available) {
        this.available = available;
    }

    public String getPackageUrl() {
        return packageUrl;
    }

    public void setPackageUrl(String packageUrl) {
        this.packageUrl = packageUrl;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.id);
        dest.writeString(this.createAt);
        dest.writeString(this.updateAt);
        dest.writeString(this.idApp);
        dest.writeString(this.packageName);
        dest.writeString(this.packageSize);
        dest.writeString(this.packageFileSize);
        dest.writeString(this.packageMd5);
        dest.writeByte(this.available ? (byte) 1 : (byte) 0);
        dest.writeString(this.packageUrl);
        dest.writeInt(this.downloadStatus == null ? -1 : this.downloadStatus.ordinal());
    }

    public void readFromParcel(Parcel source) {
        this.id = source.readString();
        this.createAt = source.readString();
        this.updateAt = source.readString();
        this.idApp = source.readString();
        this.packageName = source.readString();
        this.packageSize = source.readString();
        this.packageFileSize = source.readString();
        this.packageMd5 = source.readString();
        this.available = source.readByte() != 0;
        this.packageUrl = source.readString();
        int tmpDownloadStatus = source.readInt();
        this.downloadStatus = tmpDownloadStatus == -1 ? null : DownloadStatus.values()[tmpDownloadStatus];
    }

    public DownInfoEntity() {
    }

    protected DownInfoEntity(Parcel in) {
        this.id = in.readString();
        this.createAt = in.readString();
        this.updateAt = in.readString();
        this.idApp = in.readString();
        this.packageName = in.readString();
        this.packageSize = in.readString();
        this.packageFileSize = in.readString();
        this.packageMd5 = in.readString();
        this.available = in.readByte() != 0;
        this.packageUrl = in.readString();
        int tmpDownloadStatus = in.readInt();
        this.downloadStatus = tmpDownloadStatus == -1 ? null : DownloadStatus.values()[tmpDownloadStatus];
    }

    public static final Parcelable.Creator<DownInfoEntity> CREATOR = new Parcelable.Creator<DownInfoEntity>() {
        @Override
        public DownInfoEntity createFromParcel(Parcel source) {
            return new DownInfoEntity(source);
        }

        @Override
        public DownInfoEntity[] newArray(int size) {
            return new DownInfoEntity[size];
        }
    };
}
